// Lang_10 [immutable objects].nova // The application class. class ImmutableObjectsApp { // Application class's "main" function. public static void main( String[] args ) { // When a new Integer (primitve wrapper) object is created it is immutable (fixed value). Integer i = new Integer( 1 ); // Output the value of the Integer object at the local reference i. Stream.writeLine( "value of i before: " + i.toString( ) ); // Call the static method. method1( i ); // Output the final value of the Integer object at the local reference i. Stream.writeLine( "value of i after: " + i.toString( ) ); } // Method to demonstrate passing an argument by reference. private static void method1( Integer j ) { // This will reassign a new incremented object to local j but the original i is immutable. j++; // This will create a new Integer object and add it to local j, // then assign the result (which is also a new Integer object) to j. j += new Integer( 100 ); // Output the final value of the Integer object at the local reference j. Stream.writeLine( "local value of j: " + j.toString( ) ); } }